<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<script type="text/javascript">
			window.onload = function(){
				var username = document.getElementById("username");
				var please = document.getElementById("please");
				username.onblur = function(){
					//val是文本框输入内容 也就是string
					var val = username.value;
					//如果存在字符串长度 相当于文本框输入了内容
					if(val.length==0){
						//没有填写内容的情况
						please.style.display = 'block';
					}else{
						//填写了
						please.style.display = 'none';
					}
				}
			}
		</script>
	</head>
	<body>
		<form action="" method="post">
			用户名：<input type="text" id="username" value="admin"/>
			<br />
			<span style="color: red;display: none;" id="please">请输入用户名</span>
			<br />
			<input type="submit" value="注册"/>
		</form>
	</body>
</html>
